#ifndef SWITCHBUTTON_H
#define SWITCHBUTTON_H

#include <QWidget>
#include <QPainter>
#include <QColor>
#include <QPainterPath>
#include <QTimer>

class SwitchButton : public QWidget
{
    Q_OBJECT
public:
    explicit SwitchButton(QWidget *parent = nullptr);
    ~SwitchButton(){}
    void setCheckedState(bool checked);

private slots:
    void updateValue();

protected:
    void paintEvent(QPaintEvent *ev);
    void mousePressEvent(QMouseEvent *ev);

private:
    void drawBackground(QPainter *painter);
    void drawSlider(QPainter *painter);
    void drawText(QPainter *painter);

    int m_space;
    int m_radius;

    bool m_checked;
    bool m_showText;
    bool m_animation;

    QColor m_bgColorOn;
    QColor m_bgColorOff;
    QColor m_sliderColorOn;
    QColor m_sliderColorOff;
    QColor m_textColor;

    QString m_textOn;
    QString m_textOff;

    QTimer *m_timer;

    int m_step;
    int m_startX;
    int m_endX;

signals:
    void statusChanged(bool checked);

};

#endif // SWITCHBUTTON_H
